home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / osi / isode / dosisode / DOSISODE80.ZIP / ISODE8.WRK / UNIX / H / NETINET / IN.H next >
Encoding:
C/C++ Source or Header  |  1992-02-18  |  3.6 KB  |  122 lines

  1. /*
  2.  * Copyright (c) 1982, 1986 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  *
  6.  *    @(#)in.h    7.1 (Berkeley) 6/5/86
  7.  */
  8.  
  9. /*
  10.  * Constants and structures defined by the internet system,
  11.  * Per RFC 790, September 1981.
  12.  */
  13.  
  14. /*
  15.  * Protocols
  16.  */
  17. #define    IPPROTO_IP        0        /* dummy for IP */
  18. #define    IPPROTO_ICMP        1        /* control message protocol */
  19. #define    IPPROTO_GGP        2        /* gateway^2 (deprecated) */
  20. #define    IPPROTO_TCP        6        /* tcp */
  21. #define    IPPROTO_EGP        8        /* exterior gateway protocol */
  22. #define    IPPROTO_PUP        12        /* pup */
  23. #define    IPPROTO_UDP        17        /* user datagram protocol */
  24. #define    IPPROTO_IDP        22        /* xns idp */
  25.  
  26. #define    IPPROTO_RAW        255        /* raw IP packet */
  27. #define    IPPROTO_MAX        256
  28.  
  29.  
  30. /*
  31.  * Ports < IPPORT_RESERVED are reserved for
  32.  * privileged processes (e.g. root).
  33.  * Ports > IPPORT_USERRESERVED are reserved
  34.  * for servers, not necessarily privileged.
  35.  */
  36. #define    IPPORT_RESERVED        1024
  37. #define    IPPORT_USERRESERVED    5000
  38.  
  39. /*
  40.  * Link numbers
  41.  */
  42. #define    IMPLINK_IP        155
  43. #define    IMPLINK_LOWEXPER    156
  44. #define    IMPLINK_HIGHEXPER    158
  45.  
  46. /*
  47.  * Internet address (a structure for historical reasons)
  48.  */
  49. struct in_addr {
  50.         union  {
  51.                struct { unsigned char s_b1,s_b2,s_b3,s_b4;} S_un_b;
  52.                struct { unsigned short s_w1,s_w2;} S_un_w;
  53.                unsigned long S_addr;
  54.     } S_un;
  55. #define   s_addr S_un.S_addr
  56. #define   s_host S_un.S_un_b.s_b2
  57. #define   s_net  S_un.S_un_b.s_b1
  58. #define   s_imp  S_un.S_un_w.s_w2
  59. #define   s_impno S_un.S_un_b.s_b4
  60. #define   s_lh   S_un.S_un_b.s_b3
  61. };
  62.  
  63. /*
  64.  * Definitions of bits in internet address integers.
  65.  * On subnets, the decomposition of addresses to host and net parts
  66.  * is done according to subnet mask, not the masks here.
  67.  */
  68. #define    IN_CLASSA(i)        (((long)(i) & 0x80000000) == 0)
  69. #define    IN_CLASSA_NET        0xff000000
  70. #define    IN_CLASSA_NSHIFT    24
  71. #define    IN_CLASSA_HOST        0x00ffffff
  72. #define    IN_CLASSA_MAX        128
  73.  
  74. #define    IN_CLASSB(i)        (((long)(i) & 0xc0000000) == 0x80000000)
  75. #define    IN_CLASSB_NET        0xffff0000
  76. #define    IN_CLASSB_NSHIFT    16
  77. #define    IN_CLASSB_HOST        0x0000ffff
  78. #define    IN_CLASSB_MAX        65536
  79.  
  80. #define    IN_CLASSC(i)        (((long)(i) & 0xc0000000) == 0xc0000000)
  81. #define    IN_CLASSC_NET        0xffffff00
  82. #define    IN_CLASSC_NSHIFT    8
  83. #define    IN_CLASSC_HOST        0x000000ff
  84.  
  85. #define    INADDR_ANY        (u_long)0x00000000
  86. #define    INADDR_BROADCAST    (u_long)0xffffffff    /* must be masked */
  87.  
  88. /*
  89.  * Socket address, internet style.
  90.  */
  91. struct sockaddr_in {
  92.     short    sin_family;
  93.     u_short    sin_port;
  94.     struct    in_addr sin_addr;
  95.     char    sin_zero[8];
  96. };
  97.  
  98. /*
  99.  * Options for use with [gs]etsockopt at the IP level.
  100.  */
  101. #define    IP_OPTIONS    1        /* set/get IP per-packet options */
  102.  
  103. #define ntohl(x) (( (((unsigned long) x) >> 24)& 0x000000ff ) |\
  104.                   ( (((unsigned long) x) >> 8) & 0x0000ff00 ) |\
  105.                   ( (((unsigned long) x) << 8) & 0x00ff0000 ) |\
  106.                   ( (((unsigned long) x) << 24)& 0xff000000 ))
  107. #define ntohs(x) (( (((unsigned short) x) >> 8) |\
  108.           ( (((unsigned short) x) << 8)) & 0xffff ))
  109. #define htonl(x) (( (((unsigned long) x) >> 24)& 0x000000ff ) |\
  110.                   ( (((unsigned long) x) >> 8) & 0x0000ff00 ) |\
  111.                   ( (((unsigned long) x) << 8) & 0x00ff0000 ) |\
  112.                   ( (((unsigned long) x) << 24)& 0xff000000 ))
  113. #define htons(x) (( (((unsigned short) x) >> 8) |\
  114.           ( (((unsigned short) x) << 8)) & 0xffff ))
  115.  
  116. #ifdef KERNEL
  117. extern    struct domain inetdomain;
  118. extern    struct protosw inetsw[];
  119. struct    in_addr in_makeaddr();
  120. u_long    in_netof(), in_lnaof();
  121. #endif
  122.